package 补充.String;

public class String正则表达式 {

    public static void main(String[] args) {
        String strl="www.1000phone.com";
        boolean matcher = strl.matches("[a-zA-Z]+");//判断是否由字母数字构成
        System.out.println(matcher);
        System.out.println(strl.replaceAll("w","%"));
        System.out.println(strl.replaceFirst("w","%"));
        String strl1="192.168.0.0";
        System.out.println();
        String[] strl2=strl1.split("\\.");
        for(String s:strl2){
            System.out.print("["+s+"]");
        }
        System.out.println();
        String[] str2=strl1.split("\\.",-2);
        for(String s:str2){
            System.out.print("["+s+"]");
        }
        System.out.println();
        String[] str3=strl1.split("\\.",3);
        for(String s:str3){
            System.out.print("["+s+"]");
        }
        String[] str4=strl1.split("\\.",0);
        System.out.println();
        for(String s:str4){
            System.out.print("["+s+"]");
        }
    }
}
